Global Index
HTML5 JS API Index > DOM Tutorials & Specs

HTMLSelectElement

Extends HTMLElement.

The select element represents a control for selecting amongst a set of options.

Properties
boolean
autofocus
The autofocus IDL attribute must reflect the content attribute of the same name.
boolean
disabled
The disabled IDL attribute must reflect the disabled content attribute.
HTMLFormElement?
form
Reassociateable form-associated elements have a form IDL attribute, which, on getting, must return the element's form owner, or null if there isn't one.
NodeList
labels
Labelable elements have a NodeList object associated with them that represents the list of label elements, in tree order, whose labeled control is the element in question. The labels IDL attribute of labelable elements, on getting, must return that NodeList object.
unsigned long
length
The length IDL attribute must return the number of nodes represented by the options collection. On setting, it must act like the attribute of the same name on the options collection.
boolean
multiple
The multiple, required, and size IDL attributes must reflect the respective content attributes of the same name. The size IDL attribute has a default value of zero.
DOMString
name
The name IDL attribute must reflect the name content attribute.
HTMLOptionsCollection
options
The options IDL attribute must return an HTMLOptionsCollection rooted at the select node, whose filter matches the elements in the list of options.
boolean
required
The multiple, required, and size IDL attributes must reflect the respective content attributes of the same name. The size IDL attribute has a default value of zero.
long
selectedIndex
The selectedIndex IDL attribute, on getting, must return the index of the first option element in the list of options in tree order that has its selectedness set to true, if any. If there isn't one, then it must return −1.
HTMLCollection
selectedOptions
The selectedOptions IDL attribute must return an HTMLCollection rooted at the select node, whose filter matches the elements in the list of options that have their selectedness set to true.
unsigned long
size
The multiple, required, and size IDL attributes must reflect the respective content attributes of the same name. The size IDL attribute has a default value of zero.
DOMString
type
The type IDL attribute, on getting, must return the string "select-one" if the multiple attribute is absent, and the string "select-multiple" if the multiple attribute is present.
DOMString
validationMessage
The validationMessage attribute must return the empty string if the element is not a candidate for constraint validation or if it is one but it satisfies its constraints; otherwise, it must return a suitably localized message that the user agent would show the user if this were the only form control with a validity constraint problem.
ValidityState
validity
The validity attribute must return a ValidityState object that represents the validity states of the element. This object is live, and the same object must be returned each time the element's validity attribute is retrieved.
DOMString
value
The value IDL attribute, on getting, must return the value of the first option element in the list of options in tree order that has its selectedness set to true, if any. If there isn't one, then it must return the empty string.
boolean
willValidate
The willValidate attribute must return true if an element is a candidate for constraint validation, and false otherwise (i.e. false if any conditions are barring it from constraint validation).
Operations
void
add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long) before)
Similarly, the add() method must act like its namesake method on that same options collection.
boolean
checkValidity()
When the checkValidity() method is invoked, if the element is a candidate for constraint validation and does not satisfy its constraints, the user agent must fire a simple event named invalid that is cancelable (but in this case has no default action) at the element and return false.
Element?
item(unsigned long index)
The item(index) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument.
HTMLOptionElement?
namedItem(DOMString name)
The namedItem(name) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument.
void
remove(optional long index)
The remove() method must act like its namesake method on that same options collection when it has arguments, and like its namesake method on the ChildNode interface implemented by the HTMLSelectElement ancestor interface Element when it has no arguments.
boolean
reportValidity()
When the reportValidity() method is invoked, if the element is a candidate for constraint validation and does not satisfy its constraints, the user agent must: fire a simple event named invalid that is cancelable at the element, and if that event is not canceled, report the problems with the constraints of that element to the user; then, return false.
void
setCustomValidity(DOMString error)
The setCustomValidity(message), when invoked, must set the custom validity error message to the value of the given message argument.
voidsetter creator(unsigned long index, HTMLOptionElement? option)